package org.example;


import org.entity.User;
import org.service.BeanFactory;
import org.service.Impl.ClassPathXmlApplicationContext;
import org.service.UserService;
/**
 * Hello world!
 *
 */
public class App 
{
    public static void main(String[] args) throws Exception{
        BeanFactory factory = (BeanFactory) new ClassPathXmlApplicationContext();
        //通过工厂直接获取
        UserService userService = (UserService) factory.getBean("userService");
        //其实User也可以从工厂中获得
        User u=(User)factory.getBean("user");
        //User u = new User();
        u.setUserName("stw");
        u.setPassword("1234");
        userService.addUser(u);//打印结果
    }
}
